#include<stdio.h>
#include<iostream>
#include<string.h>
#include<map>
using namespace std;
map <string, int> Q;

int main()
{
	int n, k, m;
	scanf("%d%d", &n, &k);
	
	char str[18], str1[18];
	int distance;
	 
	while(n--)
	{
		scanf("%s", str);
		scanf("%d", &distance);
		
		if(Q.find(str)==Q.end())
		    Q[str] = k;
	}
	
	scanf("%d", &m);
	while(m--)
	{
		scanf("%s", str1);
		if(Q.find(str1)==Q.end())
		    cout<<"No Info"<<endl;  
		else
		{
			if(Q[str1]>=k)
			    printf("%d\n", Q[str1]);
			else printf("%d\n", k);
		}
	}
	return 0;
} 
